<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    });
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="CSS/Tree.css"/>
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>

<!-- DATATABLES CSS END -->

<h1 class="page-title">${listTitle}</h1>

<div class="container_12 clearfix leading">

    <section class="tabs grid_12 leading">
        <p>

        <h5>设定岗位：<strong>${examQuanSet.duty.organization.path}/${examQuanSet.duty.dutyName}</strong>
        </h5>

        </p>
        <ul class="clearfix">

        </ul>
        <section>
            <section class="clearfix" style="display: block;">

                <div id="list_content" class="clearfix">
                </div>
                <div class="tabs side grid_12 leading">
                    <div class="clear"></div>
                    <div class="grid_12">
                        <div class="form-action clearfix">
                            <input type="hidden" id="quanset_pstate" value="${maxRate}">

                            <p>
                                <input type="checkbox" id="form-all" value="1"
                                       onchange="checkAll(this,'check_item')"/><label
                                    for="form-all">全选</label>
                                <button class="button" type="button" onclick="deleteExamItem()">批量删除</button>

                                <a href="javascript:hint()" class="button"><span class="icon"
                                                                                 style="background:url(${ctx}/images/img/add.png)">&nbsp;</span>添加</a>

                                <a href="#exam/itemset_main.xhtml" class="button"><span class="icon"
                                                                                        style="background:url(${ctx}/images/img/arrow_undo.png)">&nbsp;</span>返回</a>
                            </p>
                        </div>
                    </div>
                </div>
            </section>

        </section>
    </section>


</div>

<div class="clear"></div>

<script type="text/javascript">
    //删除员工
    function deleteExamItem() {
        var checkIds = new Array();
        $("input[type='checkbox'][name='check_item']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
            return;
        }
        if (confirm("确定要删除选中的数据吗？删除后将无法恢复!")) {
            doDeleteItems(checkIds.join(","))
        }
    }

    function doDeleteItems(ids) {
        var url = "${ctx}/exam/quanitem_delete.xhtml?examQuanSet.id=${examQuanSet.id}";
        $.ajax(url, {
            type: "POST",
            data:{"itemIds":ids},
            dataType:"html",
            cache:false,
            success:function(a) {
                //return refreshListContent(a, url)
                var obj = $("#list_content");
                obj.html("");
                obj.append(a);
            },
            complete:function() {

            }
        });

    }

    function hint() {
        var p = $("#quanset_pstate").attr("value");
        if(p<100){
            window.location.href="#exam/itemset_setup_add.xhtml?organizationId=${examQuanSet.duty.organization.topOrganization.id}&examQuanSet.duty.id=${examQuanSet.duty.id}&examQuanSet.id=${examQuanSet.id}&ap="+p+"&t=<%=new java.util.Date().getTime()%>";
        }else{
            alert('比率已经达到100%，无法再添加!');
        }
    }

    $(function(){
        
        refreshListContent("${ctx}${listAction}",null);
    })
</script>

